package com.zhl.media.commonres.dialog;

import android.app.Dialog;
import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.EditText;
import android.widget.TextView;

import com.zhl.media.commonres.R;


public class WCTZDialog extends Dialog {
    private TextView tvSure,tvCancel,tvTitle,tvDes,lp,dy,lz,dt,mtw;
    private String title,des,lps,dys,lzs,dts,mtws;
    public WCTZDialog(@NonNull Context context, String title, String des,String lps,String dys,String lzs,String dts,String mtws) {
        super(context);
        this.title = title;
        this.des = des;
        this.lps = lps;
        this.dys = dys;
        this.lzs = lzs;
        this.dts = dts;
        this.mtws = mtws;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Window window = getWindow();
        window.setGravity(Gravity.CENTER);
        window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        View view = LayoutInflater.from(getContext()).inflate(R.layout.public_dialog_wctz, null);
        tvTitle = view.findViewById(R.id.title);
        tvDes = view.findViewById(R.id.des);
        lp = view.findViewById(R.id.lp);
        dy = view.findViewById(R.id.dy);
        lz = view.findViewById(R.id.lz);
        dt = view.findViewById(R.id.dt);
        mtw = view.findViewById(R.id.mtw);
        lp.setText(lps);
        dy.setText(dys);
        lz.setText(lzs);
        dt.setText(dts);
        mtw.setText(mtws);
        tvTitle.setText(title);
        tvDes.setText(des);
        tvSure = view.findViewById(R.id.id_sure);
        tvCancel = view.findViewById(R.id.id_cancel);
        tvCancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                dismiss();
            }
        });
        tvSure.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (listener!=null) {
                    listener.i();
                }
            }
        });
        setContentView(view);
        WindowManager.LayoutParams lp = getWindow().getAttributes();
        lp.width = WindowManager.LayoutParams.WRAP_CONTENT;
        lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
        getWindow().setAttributes(lp);
    }

    HallListener listener;

    public void setListener(HallListener listener) {
        this.listener = listener;
    }

    public interface HallListener {
        void i();
    }
}
